/**************************************************************************************************
* Title: Octree.h
* Authors: Gael Huber
* Description: Contains framework for a Octree as well as the logic for managing and querying its
*	contents.
**************************************************************************************************/
#ifndef __OCTREE_H__
#define __OCTREE_H__

#include "OctreeNode.h"
#include "SmurfsVector3.h"
#include <math.h>

class Octree {
public:
	Octree(void);	// Constructor
	~Octree(void);	// Destructor

	OctreeNode* buildTree(Vector3 center, Vector3 halfWidth, int stopDepth);	// Build the basis for a tree
		// based on a list of points
	void insertObject(OctreeNode* tree, SmurfsPolygon* obj, int currDepth);	// Insert an object into the tree
	bool nodeContainable(OctreeNode* tree, SmurfsPolygon* obj);	// Determines whether the node can still contain
		// the object in question or whether it lies outside
	void removeObject(SmurfsPolygon* obj);		// Removes the object from a node by altering its linked list
	void query(OctreeNode* tree, SmurfsPolygon* obj, Vector3 position);	// Queries the tree for any objects that are
		// from any nodes that encompass a particular point
	
	OctreeNode* root;	// The root node for the tree
	int depth;		// Tree depth
};

#endif